﻿// <copyright file="GlobalSetup.cs" company="Ecole Normale Supérieure">
// Released under GPLv2
// </copyright>
// <summary>Contains the GlobalSetup for Autofac for Management project.</summary>

namespace Sqwarea.Management
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Autofac;
    using Autofac.Builder;
    using Autofac.Configuration;
    using Lokad.Cloud;
    using Sqwarea.GameLogic;
    using Sqwarea.Persistence.Azure;

    /// <summary>
    /// Contains AutoFac container for Management
    /// </summary>
    internal class GlobalSetup
    {
        /// <summary>
        /// AutoFac container
        /// </summary>
        public static readonly IContainer Container;

        /// <summary>
        /// Initializes static members of the GlobalSetup class.
        /// </summary>
        static GlobalSetup()
        {
            var builder = new ContainerBuilder();

            // Lokad.Cloud
            builder.RegisterModule(new CloudModule());
            builder.RegisterModule(new ConfigurationSettingsReader("autofac"));

            // Persistence
            builder.RegisterModule(new PersistenceModule());

            // GameLogic
            builder.RegisterModule(new GameLogicBatchModule());

            Container = builder.Build();
        }
    }
}
